import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';
import { EDIT_KEYS } from '../enum';

interface Props {
  dispatch: Function,
  data: any,
  match: {
    params: {
      id: number
    }
  },
  details: object
}

@connect(({ fire_facilities }) => ({
  data: fire_facilities.editDetails
}))
class Update extends Component<Props, any> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'fire_facilities/queryEditInfoById',
      payload: {
        id: params.id,
        keys: EDIT_KEYS
      }
    })
  }

  render() {
    return (
      <section className="edit">
        <FormList data={this.props.data} key={Date.now()}/>
      </section>
    );
  }
}

export default Update;
